import 'package:flutter/material.dart';

class BottomInputDialog extends StatelessWidget {
  final String? title;
  final Function(String) confirm;
  final TextInputType type;
  final FocusNode? commentFocus;
  final TextEditingController textEditingController;
  final int? maxLength;

  const BottomInputDialog(
      {Key? key,
      this.title,
      required this.type,
      required this.confirm,
      required this.textEditingController,
      this.maxLength,
      this.commentFocus})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.transparent,
      body: Column(
        children: <Widget>[
          Expanded(
              child: GestureDetector(
            child: Container(
              color: Colors.black54,
            ),
            onTap: () {
              Navigator.pop(context);
            },
          )),
          Container(
            height: 50,
            color: Colors.white,
            padding: const EdgeInsets.symmetric(horizontal: 15),
            child: Row(
              children: <Widget>[
                const Text('请输入：'),
                Expanded(
                  flex: 1,
                  child: Container(
                    padding: const EdgeInsets.symmetric(horizontal: 6),
                    margin: const EdgeInsets.symmetric(horizontal: 6),
                    decoration: BoxDecoration(
                      border: Border(
                        bottom: BorderSide(
                          width: .5,
                          color: Colors.grey[400] ?? const Color(0x00eeeeee),
                        ),
                      ),
                    ),
                    child: TextField(
                      controller: textEditingController,
                      autofocus: true,
                      keyboardType: type,
                      textInputAction: TextInputAction.done,
                      maxLength: maxLength,
                      decoration: InputDecoration(
                        hintText: '请输入$title',
                        hintStyle:
                            const TextStyle(color: Colors.grey, fontSize: 13),
                        contentPadding: const EdgeInsets.symmetric(vertical: 6),
                        border: InputBorder.none,
                      ),
                      onSubmitted: (value) {
                        confirm(value);
                        Navigator.pop(context);
                      },
                    ),
                  ),
                ),
              ],
            ),
          )
        ],
      ),
    );
  }
}
